improve java code performance